﻿$(document).ready(function()
{
	$.ajax({
		url: "http://intranet.contoso.com/_vti_bin/LastViewedService.svc/RefreshLastViewed?ListId=00140A2E-73E4-43E7-9AF0-5B80865F2B6F&amp;ItemId=1",
		dataType: 'xml',
		success: function(data) {
			if(data.text)
			{
				var rowsNeedingrefresh = $('span[NullLastViewedId!='']');
				string ids = '';						
				$(rowsNeedingrefresh).each(function()
				{
					ids+=$(this).attr('NullLastViewedId');
				});
				$.ajax({
					url: "http://intranet.contoso.com/_vti_bin/LastViewedService.svc/GetLastViewed?ListId=00140A2E-73E4-43E7-9AF0-5B80865F2B6F&amp;ItemId=1",
					dataType: 'xml',
					success: function(data) {
						var lastVieweds = $(data.text).split(',');
						for(var i in rowsNeedingrefresh)
						{
							$(rowsNeedingrefresh[i]).text(lastVieweds[i]);
						}
					}
				});
			}
		}
	});
});